---
title:        'Bitmap to C/C++ Converter'
description:  'Convert a JPEG or PNG file to a C/C++ byte array.'
category:     [ tools ]
---

<script type="text/javascript" src="./converter.js"></script>

<div class="container" role="main">
  <div class="row">
    <div class="col-lg-12" id="bitmap-converter">
      <h1>Bitmap Converter</h1>
      <p>This tool converts a JPEG or PNG image file to a <a href="https://github.com/olikraus/u8glib">U8Glib</a>-compatible C/C++ array that can be used in Marlin as a custom <code>_Bootscreen.h</code> file or as icons for Graphical Displays. Darker colors in the source image will produce "on" pixels, while lighter colors will be converted to transparent pixels.</p>
      <p>If this tool doesn't work in your browser, use the server-side tool <a href="http://www.digole.com/tools/PicturetoC_Hex_converter.php">at digole.com</a>.</p>
      <div class="file-selector">
        <textarea id="pasted" cols="80" rows="1" wrap="soft"></textarea>
        <label class="lesser"><input type="checkbox" id="old-on" />&nbsp;Paste C++</label>
        <canvas id="preview-sm" width="32" height="32"></canvas>
        <canvas id="preview-lg" width="32" height="32"></canvas>
        <div id="err-box"></div>
        <input type="file" id="file-input" accept="image/*" /><br />
        <div class="options">
          &nbsp;&nbsp;<label><input type="checkbox" id="bin-on" />&nbsp;Binary</label>
          &nbsp;&nbsp;<label><input type="checkbox" id="ascii-on" checked="checked" />&nbsp;ASCII Art</label>
          &nbsp;&nbsp;<label><input type="checkbox" id="skinny-on" />&nbsp;Narrow</label>
          &nbsp;&nbsp;&nbsp;
          &nbsp;<label><input type="radio" name="bitmap-type" value="bits" checked="checked" />&nbsp;Bitmap</label>
          &nbsp;<label><input type="radio" name="bitmap-type" value="boot" />&nbsp;Boot</label>
          &nbsp;<label><input type="radio" name="bitmap-type" value="stat" />&nbsp;Status</label>
          <span id="stat-sub">
            :&nbsp;&nbsp;
              <select class="tbd" name="hotends" value="1">
                <option value="0">0 Nozzles</option>
                <option value="1">1 Nozzle</option>
                <option value="2">2 Nozzles</option>
                <option value="3">3 Nozzles</option>
                <option value="4">4 Nozzles</option>
              </select>
            &nbsp;&nbsp;<label class="tbd"><input type="checkbox" id="bed-on" />&nbsp;Bed</label>
            &nbsp;&nbsp;<label class="tbd"><input type="checkbox" id="fan-on" />&nbsp;Fan</label>
          </span>
        </div>
      </div>
      <div id="cpp-container">
        <p>Copy the following code into your <span id="where">program</span>:</p>
        <textarea id="output" cols="80" rows="4" readonly="readonly" wrap="soft">Select or drop an image above.</textarea>
      </div>
    </div>
  </div>
</div>
